<template>
<div>

    <van-cell-group>
        <van-nav-bar :fixe="true" :placeholder="true" title="" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-tabbar v-model="active" :fixed="false" @change="onChange">
            <van-tabbar-item>加班备案</van-tabbar-item>
            <van-tabbar-item>请休假</van-tabbar-item>
            <van-tabbar-item>离穗报备</van-tabbar-item>
            <van-tabbar-item>出国境</van-tabbar-item>
        </van-tabbar>
    </van-cell-group>

    <van-cell-group v-if="jb">
        <van-cell title="新增加班" @click="select0()" />
        <van-cell title="代申请加班" @click="select1()" />
    </van-cell-group>

    <van-cell-group v-if="qxj">
        <h3 style="margin-bottom: 1px;margin-top: 1px;margin-left: 20px;">新增请休假</h3>
        <van-cell icon="location-o" title="年休假" is-link to="" @click="check('LEAVE_ANNUAL','nxj')" value='按工作日' />
        <van-cell icon="location-o" title="调休假" is-link to="" @click="check('LEAVE_COMPENSATED','txj')" value='按自然日' />
        <!-- 探亲假(父母) LEAVE_VISIT_PARENT  探亲假(配偶) LEAVE_VISIT_SPOUSE -->
        <van-cell icon="location-o" title="探亲假" is-link to="" @click="select()" value='按自然日' />
        <!-- <van-action-sheet  title="探亲假" v-model="show" :actions="actions" @select="onSelect" /> -->
        <van-cell icon="location-o" title="哺乳假" is-link to="" @click="check('LEAVE_BREASTFEEDING','brj')" value='按自然日' />
        <van-cell icon="location-o" title="节育假" is-link to="" @click="check('LEAVE_CONTRACEPTION','jyj')" value='按自然日' />
        <van-cell icon="location-o" title="丧假" is-link to="" @click="check('LEAVE_FUNERAL','sangj')" value='按工作日' />
        <van-cell icon="location-o" title="婚假" is-link to="" @click="check('LEAVE_MARRIAGE','hj')" value='按工作日' />
        <van-cell icon="location-o" title="产假" is-link to="" @click="check('LEAVE_MATERNITY','cj')" value='按自然日' />
        <van-cell icon="location-o" title="陪产假" is-link to="" @click="check('LEAVE_PATERNITY','pcj')" value='按自然日' />
        <van-cell icon="location-o" title="护理假" is-link to="" @click="check('LEAVE_NURSING','hlj')" value='按工作日' />
        <van-cell icon="location-o" title="事假" is-link to="" @click="check('LEAVE_PERSONAL','sj')" value='按工作日' />
        <van-cell icon="location-o" title="病假" is-link to="" @click="check('LEAVE_SICK','bj')" value='按工作日' />
        <h3 style="margin-bottom: 1px;margin-top: 1px;margin-left: 20px;">请休假代理</h3>
        <van-cell icon="location-o" title="考勤员代申请" is-link to="dsqselectPage" value='按工作日' />
        <van-cell icon="location-o" title="考勤员代录入" is-link to="dlrselectPage" value='按自然日' />
    </van-cell-group>

    <van-cell-group v-if="lsbb">
        <van-cell title="新增因公离穗备案" is-link to="xjlsbb" value="" />
        <van-cell title="新增公休节假日离开广州" is-link to="gxjjrlkgz" value="" />
    </van-cell-group>

    <van-cell-group v-if="cgj">
        <van-cell title="出国（境）申请" is-link to="cgjsq" />
        <van-cell title="代退休干部录入" is-link to="cgjkqydlr" />
        <van-cell title="代退休干部申请" is-link to="cgjkqydsq" />
        <!-- <van-cell title="我的出国境" is-link to="wdcgj" /> -->
        <!-- <van-cell title="出国境审核" is-link to="cgjsh" /> -->
        <!-- <van-cell title="填写回执单" is-link to="yshqxj" /> -->
        <!-- <van-cell title="收回证件" is-link to="xj" /> -->
        <!-- <van-cell title="人事处发证、发函、呈报" is-link to="dsqselectPage" /> -->
    </van-cell-group>

    <van-tabbar v-model="active1">
        <van-tabbar-item icon="home-o" to='/index'>首页</van-tabbar-item>
        <van-tabbar-item icon="search" to='/bl'>办理</van-tabbar-item>
        <van-tabbar-item icon="friends-o" to='/indexxj'>新建</van-tabbar-item>
        <!-- <van-tabbar-item icon="setting-o">统计</van-tabbar-item> -->
        <van-tabbar-item icon="manager-o" to='/wode'>我的</van-tabbar-item>
    </van-tabbar>
</div>
</template>

<script>
import Cookies from "js-cookie";
import {
    findList
} from "@/api/fy";
import {
    Transformation
} from "@/api/common";
import {
    ActionSheet
} from 'vant';

import {
    Dialog
} from 'vant';
import {
    Check
} from '@/api/fy';
export default {
    data() {
        return {

            active: 0,
            active1: 2,
            jb: true,
            qxj: false,
            lsbb: false,
            cgj: false,
            dsh: '',
            ysh: '',
            dshqxj: '',
            yshqxj: '',
            dblxj: ''

        };
    },
    created() {
        this.active = Number(Cookies.get("active"))
        if (this.active == 0) {
            this.jb = true
            this.qxj = false
            this.lsbb = false
            this.cgj = false
        } else if (this.active == 1) {
            this.jb = false
            this.qxj = true
            this.lsbb = false
            this.cgj = false
            this.daishenheqxj();
            this.daibanlixiaojia();
            this.yishenheqingxiujia();
        } else if (this.active == 2) {
            this.jb = false
            this.qxj = false
            this.lsbb = true
            this.cgj = false
        } else if (this.active == 3) {
            this.jb = false
            this.qxj = false
            this.lsbb = false
            this.cgj = true
        }
    },
    methods: {
        onChange(index) {
            if (index == 0) {
                this.jb = true
                this.qxj = false
                this.lsbb = false
                this.cgj = false
                Cookies.set("active", 0, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 1) {
                this.jb = false
                this.qxj = true
                this.lsbb = false
                this.cgj = false
                this.daishenheqxj();
                this.daibanlixiaojia();
                this.yishenheqingxiujia();
                Cookies.set("active", 1, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 2) {
                this.jb = false
                this.qxj = false
                this.lsbb = true
                this.cgj = false
                Cookies.set("active", 2, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 3) {
                this.jb = false
                this.qxj = false
                this.lsbb = false
                this.cgj = true
                Cookies.set("active", 3, {
                    expires: 7,
                    path: "/"
                });
            }
        },

        onClickLeft() {
            this.$router.go(-1);
        },
        onSelect(item) {
            // 默认情况下点击选项时不会自动收起
            // 可以通过 close-on-click-action 属性开启自动收起
            this.show = false;
            Toast(item.name);
        },

        onClickLeft() {
            this.$router.go(-1); //返回上一层
        },
        check(type, url) {
            const obj = {
                recordType: type,
            }
            Check(obj).then(res => {
                const that = this;
                console.log(res);
                if (res.data.verCode == 1) {
                    that.$router.push({
                        path: url
                    });
                } else {
                    Dialog.alert({
                        message: res.data.msg,
                    }).then(() => {
                        // on close
                    });
                }
            })
        },
        select() {
            Dialog.confirm({
                    title: '温馨提示',
                    message: '请选择探亲类型',
                    confirmButtonText: "探望父母",
                    cancelButtonText: '探望配偶'
                })
                .then(() => {
                    this.check('LEAVE_VISIT_PARENT', 'tqjfm')
                })
                .catch(() => {
                    this.check('LEAVE_VISIT_SPOUSE', 'tqjpo')
                });
        },
        select0() {
            Dialog.confirm({
                    title: '温馨提示',
                    message: '请选择加班类型',
                    confirmButtonText: "加班备案(单次)",
                    cancelButtonText: '加班备案(多次)'
                })
                .then(() => {
                    this.$router.push({
                        path: 'xjjb',

                    })
                })
                .catch(() => {
                    this.$router.push({
                        path: 'xjjbdc',

                    })
                });
        },
        select1() {
            Dialog.confirm({
                    title: '温馨提示',
                    message: '请选择代申请加班类型',
                    confirmButtonText: "代申请加班备案(单次)",
                    cancelButtonText: '代申请加班备案(多次)'
                })
                .then(() => {
                    this.$router.push({
                        path: 'dsqjb',

                    })
                })
                .catch(() => {
                    this.$router.push({
                        path: 'dsqjbdc',

                    })
                });
        },
    }
};
</script>

<style>
</style>
